﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Itop.YHPC;
using Itop.YHPC.Model;
using Itop.YHPC.controller;

public partial class Login : System.Web.UI.Page {
    protected void Page_Load(object sender, EventArgs e) {

    }
    public string GetCompany() {
        return util.GetCompany();
    }
    protected void Button1_Click(object sender, EventArgs e) {
        
        string UserName = TextBox1.Text.ToString();
        //string Pwd = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(TextBox2.Text.ToString(),"Md5");
        string Pwd = TextBox2.Text.ToString();
        //string yzm = TextBox3.Text.ToString();
        //if (yzm.ToUpper() == Session["CheckCode"].ToString()) 
        {

            if (UserName == "") {
                util.Message(this, "警告:用户名和密码没输入!");
            } else {

                sysuser user = Global.SqlMapper.GetOne<sysuser>(string.Format("where loginid='{0}' and pwd='{1}'", UserName, Pwd));
                if (user == null) {

                    util.Message(this, "警告:用户名或密码错误啦！");
                } else {
                    Session["user"] = user;
                    Session["userprog"] = BasePage.GetUserProgs(user.LoginID);//加载用户权限表，有记录即是有权限
                    Response.Redirect("~/index.aspx");
                }

            }


        } 
        //else {
        //    util.Message(this, "提示:\\n验证码错误!");

        //}

    }
}

